//
//  Icon.swift
//  onemeetingmac
//
//  Created by 张衡 on 2020/5/7.
//  Copyright © 2020 onemeeting. All rights reserved.
//

import Foundation



struct IconData {
    var title:String!
    var image:String!
    init(title:String,image:String) {
        self.title = title
        self.image = image
    }
}

class Icon: NSView {
    
    override init(frame frameRect: NSRect) {
        super.init(frame: frameRect)
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    convenience init(data:IconData) {
        self.init()
        self.setupUI()
        self.loadData(data: data)
    }
    
    func loadData(data:IconData) {
        self.btn.normalImage = NSImage.image(name:data.image)!
        self.sTitle.stringValue = data.title
    }
    
    func setupUI() {
        self.addSubview(btn)
        btn.snp.makeConstraints { (make) in
            make.size.equalTo(btn.image!.size)
            make.centerX.equalToSuperview()
            make.centerY.equalToSuperview().offset(-10)
        }
        self.addSubview(sTitle)
        sTitle.snp.makeConstraints { (make) in
            make.top.equalTo(btn.snp.bottom).offset(5)
            make.centerX.equalToSuperview()
            make.height.equalTo(20)
            
        }
    }
    
    lazy var btn: ZHButton = {
        let btn = ZHButton()
        btn.normalImage = NSImage.image(name:"toolbar_mute_voip_normal")!
        return btn
    }()
    
    lazy var sTitle: NSLabel = {
        let lab = NSLabel.label(title: "智能客服", textColor: color_gray(255), font: NSFont.systemFont(ofSize: 12))
        lab.sizeToFit()
        lab.alignment = .center
        return lab
    }()
}
